﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using GWEB.WebBase.Entity;
using GWEB.WebBase.Utility;
using GWEB.WebFrame.Public;

namespace GWEB.WebFrame.Models
{
    public class Cond
    {
        public PageInfo Init()
        {
            PageInfo pg = new PageInfo();
            pg.Type = "Cond";
            pg.Title = "数据权限";
            pg.AddText = pg.Title + "增加";
            pg.EditText = pg.Title + "修改";
            pg.LocateText = pg.Title + "查询";
            pg.SMenuId = "CS04";
            pg.FileUrl = "../Sys/Cond";
            pg.Condition = "";
            pg.TableName = "tb_sys_cond";
            pg.KeyFieldName = "id";
            pg.PopEditHeight = 500;
            pg.PopEditWidth = 700;
            HttpSessionState session = System.Web.HttpContext.Current.Session;
            pg.dict = BasePage.getDict(session);
            pg.Sop = BasePage.Grant(session, pg.SMenuId);
            pg.Sql = @"select * from (
                        select tb_sys_cond.*,
                    	(select dname from tb_sys_dictionary where typeid='B05' and did=smodule) as smodule_cn,
                    	(select sshowname from tb_sys_users where iuserid=tb_sys_cond.iuserid) iuserid_cn,
                    	(select srolename from tb_sys_role where srolecode=tb_sys_cond.srolecode) srolecode_cn
                    	from tb_sys_cond
                    ) tb_sys_cond where 1=1 ";
            ColumnInfo cl;
            cl = new ColumnInfo(); cl.DataType = Tag.Text; cl.FieldName = "scondname"; cl.HeadText = "权限名称"; cl.ErrMessage = "权限名称:长度不能超过50"; cl.IsCheck = true; cl.Length = 50; cl.IsNull = false; cl.IsCondition = true; cl.IsUnique = true; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.DataType = Tag.Text; cl.FieldName = "smodule"; cl.HeadText = "模块名称"; cl.Visible = false; cl.DictTypeID = "B05"; cl.ErrMessage = "模块名称:必填"; cl.IsCheck = true; cl.Length = 200; cl.IsNull = false; cl.IsCondition = true; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.DataType = Tag.Text; cl.FieldName = "smodule_cn"; cl.HeadText = "模块名称"; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.DataType = Tag.Text; cl.FieldName = "iuserid"; cl.HeadText = "用户名称"; cl.Visible = false; cl.LinkTable = "tb_sys_users"; cl.LinkKeyField = "iuserid"; cl.LinkRetuField = "sshowname"; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.DataType = Tag.Text; cl.FieldName = "srolecode"; cl.HeadText = "角色名称"; cl.Visible = false; cl.LinkTable = "tb_sys_role"; cl.LinkKeyField = "srolecode"; cl.LinkRetuField = "srolename"; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.DataType = Tag.Text; cl.FieldName = "iuserid_cn"; cl.HeadText = "用户名称"; cl.IsCondition = true; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.DataType = Tag.Text; cl.FieldName = "srolecode_cn"; cl.HeadText = "角色名称"; cl.IsCondition = true; pg.AddColumn(cl);
            return pg;
        }
    }
}